<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="委托书详情" >
<div class="xm-product"
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a href="javascript:history.back(-1)">返回上一级</a>
            </div>
            <div class="panel-body demo-content">
                <div class="panel-body" style="padding-top:0px;">
                    <form id="detailForm" class="form-horizontal">
                        <div id="customerInf">
                            <h3>客户信息</h3>
                            <hr>
                            <div class="control-group">
                                <div class="pull-left">
                                    <label class="control-label">
                                        <s>*</s>
                                        客户名称：
                                    </label>
                                    <div class="controls">
                                        <input type="text" class="control-text span-width span8" id="customerName"
                                               disabled>
                                    </div>
                                </div>
                                <div class="pull-left">
                                    <label class="control-label">
                                        <s>*</s>
                                        客户地址：
                                    </label>
                                    <div class="controls">
                                        <input type="text" class="control-text span-width span8 address" disabled>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="pull-left">
                                    <label class="control-label">
                                        <s>*</s>
                                        负责人：
                                    </label>
                                    <div class="controls">
                                        <input type="text" class="control-text span-width span8 linkman" disabled>
                                    </div>
                                </div>
                                <div class="pull-left">
                                    <label class="control-label">
                                        <s>*</s>
                                        联系电话：
                                    </label>
                                    <div class="controls">
                                        <input type="text" class="control-text span-width span8 linkPhone" disabled>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <h3>检测信息</h3>
                        <hr>
                        <div class="control-group">
                            <label class="control-label">
                                检测类别：
                            </label>
                            <div class="controls">
                                <input type="text" class="control-text span-width span8" disabled id="testType">
                            </div>
                        </div>
                        <h3 class="offset2">检测项目:
                        </h3>
                        <hr>
                        <div id="projectGrid" class="xm-grid">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var Grid = BUI.Grid;
    var Store = BUI.Data.Store;
    var Data = BUI.Data;
    var Select = BUI.Select;
    var detailForm = new BUI.Form.Form({
        srcNode: '#detailForm',
        submitType: 'ajax',
        callback: function (data) {

        }
    }).render();
    var id = getQueryString('id'),//拿委托书的id
            proxyType = getQueryString('proxyType');//拿委托书的类型
    proxyType=='1'?$("#customerInf").hide():$("#customerInf").show();//类型是1情况是实验组的类型，需要隐藏委托书信息
    /*****************************************************查询单个委托书的合同信息和客户名称*****************************************************/
    (function () {
        $.ajax({
            type: 'GET',
            url: '/rest/manage/proxy/selectDetail',
            dataType: 'json',
            data: {
                id: id
            },
            success: function (data) {
                $("#customerName").val(data.data.customerName);//查询客户名称
                $(".address").val(data.data.customerAddress);//查询客户地址
                $(".linkman").val(data.data.customerLinkMan);//查询客户联系人
                $(".linkPhone").val(data.data.customerLinkPhone);//查询联系人电话

                var testType = data.data.testType;//查询检测类型
                switch (testType) {
                    case '委托书检测':
                        $("#testType").val('委托书检测');
                        break;
                    case '送样检测':
                        $("#testType").val('送样检测');
                        break;
                    case '验收检测':
                        $("#testType").val('验收检测');
                        break;
                    case '清洁生产检测':
                        $("#testType").val('清洁生产检测');
                        break;
                    case '环评检测':
                        $("#testType").val('环评检测');
                        break;
                    case '排污检测':
                        $("#testType").val('排污检测');
                        break;
                    case '其他':
                        $("#testType").val('其他');
                        break;
                }

                productStore(data.data.testProjectID, data.data.testPointAmount, data.data.testFrequency, data.data.testDayAmount, data.data.testPointName);


            }
        })
    })();
    /*********************************项目报价的列表*************************/
    /**
     * 项目报价信息
     * @type {*[]}
     */
    var proColumns = [
        {title: '检测对象', dataIndex: 'projectObjectName', elCls: "center"},
        {title: '检测项目', dataIndex: 'project', elCls: "center"},
        {title: '点数', dataIndex: 'testPointAmount', elCls: "center"},
        {title: '频数', dataIndex: 'testFrequency', elCls: "center"},
        {title: '天数', dataIndex: 'testDayAmount', elCls: "center"},
        {title: '点位名称', dataIndex: 'testPointName', elCls: "center"}
    ];
    var proStore = new Store({});
    var proGrid = new Grid.Grid({
        render: '#projectGrid',
        forceFit: true,
        columns: proColumns,
        store: proStore
    });
    proGrid.render();

    /**
     * 初始化检测项目列表数据源
     * */
    function productStore(testProjectID, testPointAmount, testFrequency, testDayAmount, testPointName) {
        $.ajax({
            type: 'GET',
            url: '/rest/manage/proxy/selectTestProjectList',
            dataType: 'json',
            data: {
                testProjectID: testProjectID
            },
            success: function (data) {
                var testPointAmountArr = testPointAmount.split(','),
                        testFrequencyArr = testFrequency.split(','),
                        testDayAmountArr = testDayAmount.split(','),
                        testPointNameArr = testPointName.split(',');
                for (var j = 0; j < data.data.length; j++) {
                    var obj = new Object();
                    obj.id = j;
                    obj.projectObjectName = data.data[j].categoryName;
                    obj.project = data.data[j].name;
                    obj.accordingTo = data.data[j].accordingTo;
                    obj.remark = data.data[j].remark;
                    obj.testPointAmount = testPointAmountArr[j];
                    obj.testFrequency = testFrequencyArr[j];
                    obj.testDayAmount = testDayAmountArr[j];
                    obj.testPointName = testPointNameArr[j];
                    proStore.add(obj);
                }
            }
        });
    }

    productStore();

</script>

</@page.pageBase>
